# import paddlehub as hub

# hub.serving start --config cpuconfig.json
# ##############################
# 语义分析
################################
# lac = hub.Module(name="lac")
# test_text = ["我爱北京天安门"]

# results = lac.cut(text=test_text, use_gpu=False, batch_size=1, return_tag=True)
# print(results)
# #{'word': ['今天', '是', '个', '好天气', '。'], 'tag': ['TIME', 'v', 'q', 'n', 'w']}
import cv2
import paddlehub as hub
human_seg = hub.Module(name='deeplabv3p_xception65_humanseg')
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
path = ['./aa.jpg']
# results = human_seg.segmentation(data={'image':path})
results = human_seg.segmentation(images=[cv2.imread(path[0])],
                                visualization=True)
# 原图
# img = mpimg.imread(path[0])
# 预测结果展示
# print(results)
for i in results:
    print(i['save_path'])
    test_img_path = i['save_path']
    img = mpimg.imread(test_img_path)
    # 展示预测结果图片
    plt.figure(figsize=(10,10))
    plt.imshow(img)
    plt.axis('off')
    plt.show()